package com.guan.ordering_sys.generator.controller;

import com.guan.ordering_sys.common.ResultApi;
import com.guan.ordering_sys.generator.service.PostService;
import com.guan.ordering_sys.param.PageParam;
import com.guan.ordering_sys.param.PostParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  PostController 前端控制器
 * </p>
 *
 * @author 关远键
 * @version v1.0.3
 * @since 2021-06-18
 */
@Api(tags = "角色管理控制器")
@RestController
@RequestMapping("/api/post")
public class PostController {

    @Autowired
    private PostService postService;

    @ApiOperation("角色列表")
    @GetMapping("/getList")
    public ResultApi getList(PageParam pageParam) {
        return ResultApi.success(postService.getList(pageParam));
    }

    @ApiOperation("角色详情")
    @GetMapping("/getById/{id}")
    public ResultApi getById(@PathVariable("id") Integer id) {
        return ResultApi.success(postService.getById(id));
    }

    @ApiOperation("添加角色")
    @PostMapping("/add")
    public ResultApi getById(PostParam param) {
        return ResultApi.success(postService.add(param));
    }

    @ApiOperation("删除角色")
    @DeleteMapping("/deleteById")
    public ResultApi deleteById(Integer id) {
        return ResultApi.success(postService.deleteById(id));
    }

    @ApiOperation("修改角色")
    @PatchMapping("/updateById")
    public ResultApi updateById(Integer id, PostParam param) {
        return ResultApi.success(postService.updateById(id, param));
    }

}

